export function getUserWork(userId, draft){
	return dispatch=>{
    fetch(BASEURL+'per/draftList?state='+draft+'&userId=' + userId)
    .then(res=>res.json())
    .then(response=>{
			this.refs.tipModal._close();
      //console.log('res',response)
      if(response.succ == '1'){
        response.list.forEach(item => {
          let img = item.tempImg;
          if(img && img.indexOf('http') == -1){
            img = IMG_URL + img;
            item.img = {uri: IMG_URL+item.tempImg}
          } else {
            item.img = {uri: item.tempImg}
          }
        })
        this.setState({
          //draftList: response.list,
          list: response.list
        })
      }
		})
		.catch(err=>{
			this.refs.tipModal._close();
		})
    DeviceStorage.get('user').then((user)=>{
      if(user){
        let userInfo = JSON.parse(user);
        dispatch(reciveUserData(userInfo))
      } 
    })
	}
	
}
function reciveUserData(user){
	return {
		type: 'USER_UPDATE_SUCC',
		user
	}
}
function fetchUserData(data) {
	return {
		type: "USER_UPDATE",
		loading: true,
		data: data
	}
}
function fetchUserError() {
	return {
		type: "USER_UPDATE_ERROR"
	}
}